package com.tiniplanet.webgate.web.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.ui.ModelMap;

import com.tiniplanet.webgate.web.view.MenuItem;

public class PageController extends BaseController {

	protected List<MenuItem> tabMenu;
	protected List<MenuItem> sideMenu;

	protected static final int TAB_MENU_NEWS_INDEX = 0;
	protected static final int TAB_MENU_REPORT_INDEX = 1;

	protected static final int SIDE_MENU_GENERAL_INDEX = 0;
	protected static final int SIDE_MENU_USER_INDEX = 1;

	public PageController() {
		tabMenu = new ArrayList<MenuItem>();
		sideMenu = new ArrayList<MenuItem>();
	}

	protected void resetTabMenu() {
		for (MenuItem mnu : tabMenu) {
			mnu.setActive(false);
		}
	}

	protected void resetSideMenu() {
		for (MenuItem mnu : sideMenu) {
			mnu.setActive(false);
		}
	}

	protected void addItemToTabMenu(String url, String title, String cssClass, boolean active) {
		MenuItem item = new MenuItem(url, title, cssClass, active);
		tabMenu.add(item);
	}

	protected void addItemToSideMenu(String url, String title, String cssClass, boolean active) {
		MenuItem item = new MenuItem(url, title, cssClass, active);
		sideMenu.add(item);
	}

	protected void setMenu(ModelMap modelMap) {
		modelMap.addAttribute("sideMenu", sideMenu);
		modelMap.addAttribute("tabMenu", tabMenu);
	}

}
